package com.cyj.dream.admin;

import cn.hutool.core.date.DateUtil;
import com.cyj.common.job.annotation.EnableDreamXxlJob;
import com.cyj.dream.admin.contacts.AdminConstant;
import com.cyj.dream.security.annotation.EnableDreamResourceServer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.extern.slf4j.Slf4j;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.cloud.client.discovery.EnableDiscoveryClient;
import org.springframework.context.annotation.Bean;

import java.time.format.DateTimeFormatter;

/**
 * @Description: 梦享云--后台项目管理平台
 * @BelongsProject: DreamChardonnay
 * @BelongsPackage: com.cyj.dream.admin
 * @Author: ChenYongJia
 * @CreateTime: 2021-10-25 09:46
 * @Email: chen87647213@163.com
 * @Version: 1.0
 */
@Slf4j
@EnableCaching
@EnableDiscoveryClient
@EnableDreamXxlJob
@EnableDreamResourceServer
@MapperScan(AdminConstant.MAPPER_URL)
@SpringBootApplication(scanBasePackages = {AdminConstant.SCAN_BASE_PACKAGES_URL})
public class DreamAdminBpmApplication {

    /**
     * 项目启动方法
     *
     * @param args the input arguments
     * @date 2021-9-26
     * @author Sunny Chen
     */
    public static void main(String[] args) {
        log.info("梦享云--后台项目管理平台项目开始启动ing！======>{}", DateUtil.now());
        // https://blog.csdn.net/Hello_World_QWP/article/details/115969198
        System.setProperty("nacos.logging.default.config.enabled","false");
        SpringApplication.run(DreamAdminBpmApplication.class);
        log.info("梦享云--后台项目管理平台项目启动成功ing.......！======>{}", DateUtil.now());
    }


    /**
     * 注册乐观锁插件
     *
     * @date 2021-9-26
     * @author Sunny Chen
     */
    /*@Bean
    public MybatisPlusInterceptor optimisticLockerInnerInterceptor(){
        MybatisPlusInterceptor interceptor = new MybatisPlusInterceptor();
        interceptor.addInnerInterceptor(new OptimisticLockerInnerInterceptor());
        return interceptor;
    }*/

    @Bean
    public LocalDateTimeSerializer localDateTimeDeserializer() {
        return new LocalDateTimeSerializer(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"));
    }

}
